//
//  SingerTableViewCell.swift
//  ShareMusic
//
//  Created by 胡岩 on 16/5/3.
//  Copyright © 2016年 胡岩. All rights reserved.
//

import UIKit

class SingerTableViewCell: UITableViewCell {

    var model:SingerModel?
    
    var pic:UIImageView?
    var name:UILabel?
    var details:UILabel?
    var shadow:UIImageView?
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.pic = UIImageView.init()
        self.name = UILabel.init()
        self.details = UILabel.init()
        self.shadow = UIImageView.init()
        self.pic?.contentMode = UIViewContentMode.ScaleAspectFill
        self.pic?.layer.masksToBounds = true
        self.contentView.addSubview(self.pic!)
        self.contentView.addSubview(self.shadow!)
        self.contentView.addSubview(self.name!)
        self.contentView.addSubview(self.details!)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        self.pic?.frame = self.contentView.bounds
        self.shadow?.frame = self.contentView.bounds
        self.shadow?.backgroundColor = UIColor.blackColor()
        self.shadow?.alpha = 0.3
        self.name?.frame = CGRectMake(0, 50, self.contentView.frame.size.width, 20)
        self.name?.textColor = UIColor.whiteColor()
        self.name?.font = UIFont.systemFontOfSize(20)
        self.name?.textAlignment = NSTextAlignment.Center
        self.details?.frame = CGRectMake(0, (self.name?.frame.origin.y)! + (self.name?.frame.size.height)! + 30, self.contentView.frame.size.width, 20)
        self.details?.font = UIFont.systemFontOfSize(15)
        self.details?.textColor = UIColor.whiteColor()
        self.details?.numberOfLines = 2
        self.details?.textAlignment = NSTextAlignment.Center
    }
    
    func model(model:SingerModel) {
        self.model = model
        self.pic?.sd_setImageWithURL(NSURL.init(string: model.pic_url!), placeholderImage: nil)
        self.name?.text = model.title
        self.details?.text = model.details
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
